#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int min = 0x3f3f3f3f;
	int pos = 0;

	for (int i = 0;i < n; i++)
	{
		int min = 0x3f3f3f3f;
		for (int j = i; j < n; j++)
		{
			if (min > arr[j])
			{
				min = arr[j];
				pos = j;
			}
		}
		swap(arr[i], arr[pos]);
		if(i==n-1)
			printf("sorted array: ", i + 1);
		else
			printf("step %d: ", i + 1);
		for (auto x : arr)
		{
			cout << x << " ";
		}
		cout << endl;
	}

	return 0;
}